<template>
  <div>
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          prop="username"
          label="登录人"
          width="180">
      </el-table-column>
      <el-table-column
          prop="nickname"
          label="昵称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="rolename"
          label="职位"
          width="180">
      </el-table-column>
      <el-table-column
          prop="ip"
          label="ip地址"
          width="200">
      </el-table-column>
      <el-table-column
          prop="creatime"
          label="生产时间"
          width="200">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="200">
        <template slot-scope="scope">
          <el-button v-if="tokename=='admin'||tokename=='yyc'||tokename=='scf'||tokename=='dxj'||tokename=='lk'||tokename=='lyb'" size="small" type="text" @click="exit(scope.row)">
          <span style="color: #43e8ec;font-size: 20px">
          <i class="el-icon-moon-night"></i>
          </span>
          </el-button>

          <el-button size="small" type="text" @click="show(scope.row)">
            <span style="color: #00ccbd;font-size: 20px">
            <i class="el-icon-menu"></i>
            </span>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>

</template>

<script>
export default {
  name: "OnlineView",
  data() {
    return {
      tableData:[],
      tokename:sessionStorage.getItem("loginName")
    }
  }, methods: {
    list(){
      this.axios.post("userservice/user/onlinelist").then(res=>{
        this.tableData=res.data.data;
      })
    }, exit(row) {
      this.axios.post("http://localhost:10010/userservice/user/forceduser",row).then(res => {
        if (res.data.code==200) {
          this.$message.success(res.data.msg);
          this.list();
        } else {
          this.$message.success(res.data.msg);
        }
      })
    },

  }, created() {
    this.list();
  }
}
</script>

<style scoped>

</style>
